package com.zzyl.job;

import com.zzyl.service.AlertRuleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Slf4j
@Component
public class MyTask {

    @Autowired
    private AlertRuleService alertRuleService;

//    @Scheduled(fixedRate = 2000) //固定速率，每隔2秒执行一次方法
//    @Scheduled(cron = "0 1-30 * * * ?")
//    public void task(){
//        System.out.println(LocalDateTime.now());
//    }

    @Scheduled(cron = "0 */1 * * * *")
    public void task2(){
        alertRuleService.alertFilter();
        log.info("执行定时任务2");
    }
}
